-
Notifications
You must be signed in to change notification settings - Fork 59
[QEff. Finetune]: Added support to sync gradients across devices during optimizer step only. #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
quic-swatia
reviewed
Jul 7, 2025
Signed-off-by: Meet Patel <[email protected]>
Signed-off-by: Meet Patel <[email protected]>
Signed-off-by: meetkuma <[email protected]>
Signed-off-by: meetkuma <[email protected]>
Signed-off-by: meetkuma <[email protected]>
quic-mamta
approved these changes
Jul 9, 2025
quic-swatia
approved these changes
Jul 9, 2025
quic-amitraj
pushed a commit
that referenced
this pull request
Jul 10, 2025
…ng optimizer step only. (#477) Disabling gradient is necessary when using gradient_accumulation_step > 1 with ddp enabled. Currently, we are syncing gradient at every loss.backward() call, which is called at all steps. When using gradient accumulation, the weight update during opt.step() step. Only during that step, the gradients across each devices should sync with each other. with model.no_sync() --> context manager solves this issue. Here, we are not using it but instead setting ddp_model.require_backward_grad_sync to True or False depending on which step we are. --------- Signed-off-by: Meet Patel <[email protected]> Signed-off-by: meetkuma <[email protected]> Signed-off-by: Amit Raj <[email protected]>
quic-amitraj
pushed a commit
that referenced
this pull request
Jul 10, 2025
…ng optimizer step only. (#477) Disabling gradient is necessary when using gradient_accumulation_step > 1 with ddp enabled. Currently, we are syncing gradient at every loss.backward() call, which is called at all steps. When using gradient accumulation, the weight update during opt.step() step. Only during that step, the gradients across each devices should sync with each other. with model.no_sync() --> context manager solves this issue. Here, we are not using it but instead setting ddp_model.require_backward_grad_sync to True or False depending on which step we are. --------- Signed-off-by: Meet Patel <[email protected]> Signed-off-by: meetkuma <[email protected]> Signed-off-by: Amit Raj <[email protected]>
quic-amitraj
pushed a commit
that referenced
this pull request
Jul 10, 2025
…ng optimizer step only. (#477) Disabling gradient is necessary when using gradient_accumulation_step > 1 with ddp enabled. Currently, we are syncing gradient at every loss.backward() call, which is called at all steps. When using gradient accumulation, the weight update during opt.step() step. Only during that step, the gradients across each devices should sync with each other. with model.no_sync() --> context manager solves this issue. Here, we are not using it but instead setting ddp_model.require_backward_grad_sync to True or False depending on which step we are. --------- Signed-off-by: Meet Patel <[email protected]> Signed-off-by: meetkuma <[email protected]>
quic-dhirajku
pushed a commit
to quic-dhirajku/efficient-transformers
that referenced
this pull request
Aug 4, 2025
…ng optimizer step only. (quic#477) Disabling gradient is necessary when using gradient_accumulation_step > 1 with ddp enabled. Currently, we are syncing gradient at every loss.backward() call, which is called at all steps. When using gradient accumulation, the weight update during opt.step() step. Only during that step, the gradients across each devices should sync with each other. with model.no_sync() --> context manager solves this issue. Here, we are not using it but instead setting ddp_model.require_backward_grad_sync to True or False depending on which step we are. --------- Signed-off-by: Meet Patel <[email protected]> Signed-off-by: meetkuma <[email protected]>
quic-dhirajku
pushed a commit
to quic-dhirajku/efficient-transformers
that referenced
this pull request
Aug 4, 2025
…ng optimizer step only. (quic#477) Disabling gradient is necessary when using gradient_accumulation_step > 1 with ddp enabled. Currently, we are syncing gradient at every loss.backward() call, which is called at all steps. When using gradient accumulation, the weight update during opt.step() step. Only during that step, the gradients across each devices should sync with each other. with model.no_sync() --> context manager solves this issue. Here, we are not using it but instead setting ddp_model.require_backward_grad_sync to True or False depending on which step we are. --------- Signed-off-by: Meet Patel <[email protected]> Signed-off-by: meetkuma <[email protected]> Signed-off-by: Dhiraj Kumar Sah <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Disabling gradient is necessary when using gradient_accumulation_step > 1 with ddp enabled.
Currently, we are syncing gradient at every loss.backward() call, which is called at all steps. When using gradient accumulation, the weight update during opt.step() step. Only during that step, the gradients across each devices should sync with each other.
with model.no_sync() --> context manager solves this issue.
Here, we are not using it but instead setting ddp_model.require_backward_grad_sync to True or False depending on which step we are.